<?php
defined('_JEXEC') or die('Restricted access'); 
JHTML::_('behavior.tooltip'); 
 
$listOrder    = @$this->lists['order'];
$listDirn    = @$this->lists['order_Dir'];
$saveOrder    = $listOrder == 'c.ordering';
$user = &JFactory::getUser();

?>
<script type="text/javascript">
function submitform(pressbutton)
{
    var form = document.adminForm;
       if (pressbutton)
    {form.task.value=pressbutton;}

    if ((pressbutton=='add'))
    {
          form.controller.value="transaction";
    }
    try 
    {
        form.onsubmit();
    }
    catch(e){}
    form.submit();
}
</script>
<form id="adminForm"  action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" >
	<?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
	<?php else : ?>
		<div id="j-main-container">
	<?php endif;?>
		<br clear="all">	
    	<div id="filter-bar" class="btn-toolbar">
		<div class="filter-search btn-group pull-left fltlft">
			<label for="filter_search" class="element-invisible">Search</label>
			<input type="text" name="search" id="search" 
			placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" 
			value="<?php echo $this->search ?>"  title="" />
		</div>		
		<div class="filter-search btn-group pull-left fltlft">
			<button type="submit" class="btn"><i class="icon-search"></i></button>
			<button type="button" class="btn" onclick="document.id('search').value=''; this.form.submit();"><i class="icon-remove"></i></button>
		</div>
		<div class="btn-group pull-right hidden-phone fltrt">
			<?php
				
				echo $this->lists['user'];
			?>
		</div>
	</div>
	<br clear="all">
    <div id="editcell">
        <table class="table table-striped adminlist">
        <thead>
            <tr>
                <th width="5">
                    <?php echo JText::_( 'NUM' ); ?>
                </th>
                <th width="20">
                    <?php echo JHtml::_('grid.checkall'); ?>
                </th>
                <th width="20">
                    <?php echo JHTML::_('grid.sort',  'ID', 'c.id', $listDirn, $listOrder ); ?>
                </th>
                   <th class="title" nowrap="nowrap" >
                    <?php echo JHTML::_('grid.sort',  'File name', 'c.name', $listDirn, $listOrder ); ?>
                   </th>
                   <th class="title" nowrap="nowrap" >
                    <?php echo JHTML::_('grid.sort',  'Status', 'c.product_id', $listDirn, $listOrder ); ?>
					</th>
                <th nowrap="nowrap" width="15%">
                       <?php echo JHTML::_('grid.sort',  'Created by ', 'u.name', $listDirn, $listOrder ); ?>
                </th>
                <th nowrap="nowrap" width="15%">
                       <?php echo JHTML::_('grid.sort',  'Created date ', 'c.created_date',$listDirn, $listOrder ); ?>
                </th>
            </tr>
        </thead>
        <tbody>
        <?php
           $k = 0;
        for ($i=0, $n= count( $this->items ); $i < $n; $i++):
            $ordering    = ($listOrder == 'c.ordering');
            $row = &$this->items[$i];
            $checked     = JHTML::_('grid.checkedout',   $row, $i);
            
            $canChange	= $user->authorise('core.edit.state', 'com_wrd.transaction.'.$row->id);
			$published 	= JHTML::_('jgrid.published', $row->published, $i,'transaction.', $canChange,'cb');
            ?>
            <tr class="<?php echo "row$k"; ?>"  >
                <td>
                    <?php echo($i+1); ?>
                </td>
                <td>
                    <?php echo $checked; ?>
                </td>
                <td>
                    <?php echo $row->id; ?>
                </td>
                <td>
                <a href="
                <?php if($row->product_id == 0)
                        echo 'index.php?option=com_wrd&controller=transaction&layout=formimport&id='.$row->id;
                    if($row->product_id == -1)
                        echo 'index.php?option=com_wrd&controller=transaction&layout=formconvert&id='.$row->id;
                    if($row->product_id == -2)
                        echo 'javascript:void(null)';
                    ?>    
                    ">
                    <?php echo $row->caption; ?>
                    </a>
                </td>
                <td>
                    <?php if($row->product_id == 0)
                        echo 'Upload';
                    if($row->product_id == -1)
                        echo 'Import';
                    if($row->product_id == -2)
                        echo 'Convert';
                    ?>
                </td>
                <td>
                    <?php echo $row->username; ?>
                </td>
                <td>
                    <?php echo $row->dateadd; ?>
                </td>                
            </tr>
            <?php
            $k = 1 - $k;
        endfor ;
        ?>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="16">
                    <?php
                         echo $this->pagination->getListFooter();
                    ?>
                </td>
            </tr>
        </tfoot>
        </table>
    </div>

    <input type="hidden" name="controller" value="transaction" />
    <input type="hidden" name="option" value="com_wrd" />
    <input type="hidden" name="task" value="" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
    <?php 
        echo JHTML::_( 'form.token' ); 
    ?>
</form>